#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    int findMaxForm(vector<string>& strs, int m, int n) {
        int s = strs.size();
        vector<vector<int>> dp(m + 1, vector<int>(n + 1));
        for (int i = 1; i <= s; i++)
        {
            int one = 0, zero = 0;
            for (auto c : strs[i - 1]) if (c == '1') one++; else zero++;
            for (int j = m; j >= zero; j--)
                for (int k = n; k >= one; k--)
                    dp[j][k] = max(dp[j][k], dp[j - zero][k - one] + 1);
        }
        return dp[m][n];
    }
};